/*
 * Class NPCOption2
 *
 * Version 1.0
 *
 * Saturday, August 23, 2008
 *
 * Created by Palidino76
 */

package palidino76.rs2.io.packets;

import palidino76.rs2.Engine;
import palidino76.rs2.npcs.*;
import palidino76.rs2.player.skills.*;
import palidino76.rs2.player.Player;
import palidino76.rs2.util.Misc;

public class NPCOption2 implements Packet {
    /**
     * Handles the second NPC option.
     * @param p The Player which the frame should be handled for.
     * @param packetId The packet id this belongs to.
     * @param packetSize The amount of bytes being recieved for this packet.
     */
    public void handlePacket(Player p, int packetId, int packetSize) {
        if (p == null || p.stream == null) {
            return;
        }

        int npcId = p.stream.readUnsignedWordBigEndianA();

        p.clickId = npcId;
        p.clickX = Engine.npcs[npcId].absX;
        p.clickY = Engine.npcs[npcId].absY;
	p.requestFaceTo(p.clickId);
	NPC n = Engine.npcs[p.clickId];
	PlayerThieving playerThieving = new PlayerThieving(p);
	int k = p.skillLvl[10];

        switch (n.npcType) {
		case 549:
		p.viewings = 1;
		p.shopid = 5;
		p.frames.showInterface(p, 278);
		p.frames.setItems(p, 278, 89, 94, p.shop5, p.shop5n);
		p.frames.setString(p, "                                       Slayer Shop", 278, 88);
		break;

		case 519:
		p.viewings = 1;
		p.shopid = 1;
		p.frames.showInterface(p, 278);
		p.frames.setItems(p, 278, 89, 94, p.shop1, p.shop1n);
		p.frames.setString(p, "                                       Runes", 278, 88);
		break;

		case 522:
		p.viewings = 1;
		p.shopid = 4;
		p.frames.showInterface(p, 278);
		p.frames.setItems(p, 278, 89, 94, p.shop4, p.shop4n);
		p.frames.setString(p, "                                       General St00f", 278, 88);
		break;
		
		case 2258:
		p.viewings = 1;
		p.shopid = 2;
		p.frames.showInterface(p, 278);
		p.frames.setItems(p, 278, 89, 94, p.shop2, p.shop2n);
		p.frames.setString(p, "                                       Mage of Zamorak's Runes Shop", 278, 88);
		break;
		
		case 81:
		p.viewings = 1;
		p.shopid = 3;
		p.frames.showInterface(p, 278);
		p.frames.setItems(p, 278, 89, 94, p.shop3, p.shop3n);
		p.frames.setString(p, "                                            Castlewars Shop", 278, 88);
		break;

		case 1:
		case 2:
		case 3:
		p.openBank();
		break;
		case 9:
		case 32:
			p.thievingType = 9;
			p.thiefNPC = true;
			break;

		case 494:
		case 495:
		case 496:
		case 44:
			p.NpcWanneTalk = 44;
			p.NpcDialogueSend = false;
		break;

		case 5:
		case 6:
		case 11:
		case 19:
		case 14:
		case 36:
		case 65:
		case 147:
		/* Edit 8 */
		case 1157:
		case 149:
		case 150:
			p.openBank();
		break;

		case 316: // Fish Trout
			p.NpcWanneTalk = 326;
			p.NpcDialogueSend = false;
			break;

		case 312: // Fish Shark
			p.NpcWanneTalk = 322;
			p.NpcDialogueSend = false;
			break;

		case 313: // Fish Manta
			p.NpcWanneTalk = 323;
			p.NpcDialogueSend = false;
			break;

		case 6538: // BH Bank
			p.openBank();
			break;

        default:
            Misc.println("[" + Misc.optimizeText(p.username) + "] Unhandled npc option 2: " + n.npcType);
            break;
        }
    }
}
